{{- $collapsed := default false .Site.Params.sidebar.collapsed }}
{{- $count := default .Site.Params.recentPostCount .Params.recentPostCount }}
{{- $sections := .Site.Params.mainSections }}
{{- if in (slice "posts" "docs") .Type }}
  {{- $sections = slice .Type }}
{{- end }}
{{- if and $count (default false .Site.Params.sidebar.recentPosts) }}
  <div class="accordion recent-posts">
    <section class="row card component">
      <div class="card-header">
        <h2 class="card-title my-2 fs-4 text-surface d-none d-lg-block">
          {{ i18n "recent_posts" }}
        </h2>
        <a
          class="accordion-button d-lg-none mb-1 shadow-none p-0 bg-transparent{{ cond $collapsed ` collapsed` `` }}"
          role="button"
          data-bs-toggle="collapse"
          href="#recent-posts"
          aria-expanded="{{ cond $collapsed `false` `true` }}"
          aria-controls="recent-posts">
          {{ i18n "recent_posts" }}
        </a>
      </div>
      <div
        class="card-body collapse accordion-collapse accordion-body d-lg-block{{ cond (not $collapsed) ` show` `` }}"
        id="recent-posts">
        <ul class="post-list list-unstyled ms-1">
          {{- range first $count (where site.RegularPages.ByDate.Reverse "Type" "in" $sections) }}
            <li class="mb-2">
              <a href="{{ .RelPermalink }}">{{ partial "helpers/title" . }}</a>
            </li>
          {{- end }}
        </ul>
      </div>
    </section>
  </div>
{{- end }}
